package com.example.demo.bean;

import java.time.Duration;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import javafx.fxml.Initializable;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

/**
 * @program: SpringAOP
 * @ClassName Dog
 * @description:
 * @author: zsn
 * @create: 2023-08-14 18:44
 * @Version 1.0
 **/
public class Dog implements InitializingBean, DisposableBean, BeanNameAware {

    private String name;

    public Dog() {
        System.out.println("1.实例化");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        System.out.println("2.依赖注入");
        this.name = name;
    }

    public void MyInit(){
        System.out.println("6.init-method");
    }

    public void MyDestory(){
        System.out.println("10.destory-method");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("9.DisposableBean方法的执行");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("5.InitializingBean方法的执行");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("3.执行Aware接口的方法，如 BeanNameAware、BeanFactoryAware");
    }

    public static void main(String[] args) {
//        int a =1;
//        int b =2;
//        long c =10l;
//        double v = (double) (a+b)/c;
//        int round = (int) Math.round(v * 100);
//        int i = 100 - round;
//        System.out.println(i);

        LocalDate today = LocalDate.now();

        // 减去一天，得到昨天的日期
        LocalDate yesterday = today.minusDays(1);

        // 打印昨天的日期
        System.out.println("昨天的日期是: " + yesterday);
    }
}